Both are varieties of online advertising.
Contextual advertising is shown to people who are looking for something now or before in the context of their targeted interest. Therefore, the best way to deal with such advertising is the search engine - Google (it knows more about our desires).
Targeted advertising is aimed at audiences that are selected on various grounds: socio-demographic, long-term interests, geo-location, use of various technologies. Social media algorithms and advertising systems do a great job with this. However, Google has more targeting capabilities than Facebook.
As you can see, all of the most important players in the online advertising market today use both types of advertising to a greater or lesser extent: contextual and targeted advertising.